<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <link href="/static/css/index.css" rel="stylesheet">
</head>
<body>
<h1 align='center' style="font-size:30px;color:red;font-weight: bold;">
    首页
</h1>
<div>
    <div>
        {% if name %}
            <p>你好！{{ name }}</p>
        {% else %}
            <a href='{% url "login" %}'>跳转至登录login</a>
        {% endif %}
        {% if name %}
            <a href="{% url 'logout' %}">退出登录</a>
        {% endif %}
    </div>
<div>
    <a href="/car/">查看购物车</a>
</div>
    {#    <div style="width: 180px;margin: auto;margin-bottom: 50px">#}
    {#        <table>#}
    {#            <thead>#}
    {#            <tr>#}
    {#                <th>学生姓名</th>#}
    {#                <th>学生成绩等级</th>#}
    {#            </tr>#}
    {#            </thead>#}
    {#            <tbody style="text-align: center;">#}
    {#            {% for item in students %}#}
    {#                <tr>#}
    {#                    <td>{{ item.name }}</td>#}
    {#                    {% if item.score >= 80 %}#}
    {#                        <td>A</td>#}
    {#                    {% elif  item.score >= 70 %}#}
    {#                        <td>B</td>#}
    {#                    {% elif item.score >= 60 %}#}
    {#                        <td>C</td>#}
    {#                    {% else %}#}
    {#                        <td>D</td>#}
    {#                    {% endif %}#}
    {#                </tr>#}
    {#            {% endfor %}#}
    {##}
    {#            </tbody>#}
    {#        </table>#}
    {#    </div>#}
    <div class="search">
        <form method="get" action="/index/">
            <div><input name="word" type="text" placeholder="请搜索"></div>
            <div>
                <button type="submit">搜索</button>
            </div>
        </form>
    </div>
    <div class="goods-show">
        <table>
            <thead>
            <tr>
                <th>#</th>
                <th>商品图片</th>
                <th>商品序号</th>
                <th>商品名称</th>
                <th>商品价格</th>
                <th>商品数量</th>
            </tr>
            </thead>
            <tbody style="text-align: center;" >
            {% for item in goods %}
                <tr>
                    <td>{{ forloop.counter }}</td>
                    <td><img src='{{ item.img }}' style="width: 40px;height: 40px"></td>
                    <td>{{ item.gid }}</td>
                    <td><a href="/commodity/?gid={{ item.gid }}">{{ item.name }}</a></td>
                    <td>{{ item.price }}</td>
                    <td>{{ item.count }}</td>
                </tr>
            {% endfor %}

            </tbody>
            <tfoot>
            <tr>
                <th colspan="6">
                    {% for foo in page_show %}
                        <a href="?page={{ foo }}">{{ foo }}</a>
                    {% endfor %}
                </th>
            </tr>
            </tfoot>
        </table>
    </div>
    <div class="page">
        <div>
            <a href="?page=1"><span>首页</span></a>
        </div>
        {% if page_data.has_previous == 1 %}
            <div>
                <a href="?page={{ page_data.has_previous_num }}"><span><<</span></a>
            </div>
        {% endif %}
        <div>
            <a><span>{{ page }}</span></a>
        </div>
        {% if page_data.has_next == 1 %}
            <div>
                <a href="?page={{ page_data.has_next_num }}"><span>>></span></a>
            </div>
        {% endif %}
        <div>
            <a href="?page={{ page_data.count_page }}"><span>页尾</span></a>
        </div>
    </div>
</div>
</body>
</html>